package com.albaba.designpattern.factory.text_002.controller;

import com.albaba.designpattern.factory.text_001.entity.AwardInfo;
import com.albaba.designpattern.factory.text_001.entity.DiscountResult;
import com.albaba.designpattern.factory.text_001.entity.SmallGiftInfo;
import com.albaba.designpattern.factory.text_001.service.DiscountService;
import com.albaba.designpattern.factory.text_001.service.SmallGiftService;
import com.albaba.designpattern.factory.text_001.service.YouKuMemberService;
import com.albaba.designpattern.factory.text_002.entity.ResponseResult;
import com.albaba.designpattern.factory.text_002.factory.FreeGoodsFactory;
import com.albaba.designpattern.factory.text_002.service.IFreeGoods;

import java.util.UUID;

/**
 * @Description: 发放奖品
 * @Author zx
 * @Date 2025/2/19 10:46
 * @Version 1.0
 */
public class DeliverController {

    /**
     * 按照类型的不同发放奖品 (奖品类型 1 打折券, 2 优酷会员, 3 小礼品)
     * @param
     */
    public static ResponseResult awardToUser(AwardInfo awardInfo) {
        try{
            IFreeGoods instance = FreeGoodsFactory.getInstance(1);
            return instance.sendFreeGoods(awardInfo);
        }catch (Exception e){
            e.printStackTrace();
            return new ResponseResult("500", "发放奖品失败", null);
        }
    }

    public static void main(String[] args) {

        AwardInfo awardInfo = new AwardInfo();
        awardInfo.setAwardTypes("1");
        awardInfo.setUid(UUID.randomUUID().toString());
        awardInfo.setAwardNumber("MD23532");
        awardToUser(awardInfo);
    }

}
